package com.mybank.myaccounts.repository;

import com.mybank.common.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface UserRepository extends JpaRepository<User, Long> {
    
    @Query("SELECT c.customerId FROM Customer c WHERE c.user.userId = :userId")
    Optional<Long> findCustomerIdByUserId(@Param("userId") Long userId);
    
    @Query("SELECT c.user.userId FROM Customer c WHERE c.customerId = :customerId")
    Optional<Long> findUserIdByCustomerId(@Param("customerId") Long customerId);
}